Repository navigation
Read contained value sets only at their own list positions - #10
Draft
PSchmiedmayer wants to merge 2 commits into
Draft
PSchmiedmayer wants to merge 2 commits into
PSchmiedmayer wants to merge 2 commits into
Conversation
ValueSetEditor takes the position of a value set in the contained list as a prop and writes to the entry it finds there. Read that entry only when the index is a number naming one of the list's own entries, so a key such as __proto__ cannot resolve to a prototype.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ Current situation & Problem
ValueSetEditoris part of the public React API and takes the position of a value set in the questionnaire'scontainedlist as itsindexprop.The editor and its id field read
contained[index]and then write to the entry they found, for exampletarget.id = nextwhen the id is renamed.An
indexsuch as"__proto__"or"constructor"would resolve toArray.prototypeor theArrayconstructor instead of a list entry.The existing
isValueSetandisObjectchecks reject those values today, but the write path itself does not limit the lookup to list entries, and CodeQL reports it as a prototype-polluting assignment (js/prototype-polluting-assignment).⚙️ Release Notes
ValueSetEditorreads a contained entry only whenindexis a number that names one of the list's own entries.Any other
index, including a numeric string such as"0", renders nothing and never reaches a store update.contained[index]in the value set editor go through one helper, so the rendered editor, title and code edits, and id renames use the same check:The number check rejects every string key before the lookup, and the own-entry check accepts exactly the positions that exist in the array.
Together they cover inherited keys that a list of forbidden names could miss.
Valid indices behave as before; a
containedvalue that is not an array is now ignored here, ascontainedValueSetsandremoveContainedalready do.📚 Documentation
The helper's inline documentation states why the lookup is restricted.
The public API is unchanged, so the package READMEs need no update.
✅ Testing
valueSets.test.tsxadds a case where a host plugin rendersValueSetEditorfor index0and for the keys"__proto__","constructor","prototype"and"0".Only the editor for index
0appears, renaming its id still updates the document, and neitherArray.prototypenorObject.prototypegains anidproperty.Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: